package cn.nubia.admin.sysconfig.service;

import cn.nubia.admin.common.mybatis.bean.Query;
import cn.nubia.admin.common.mybatis.service.BaseServiceImpl;
import cn.nubia.admin.sysconfig.bean.Dict;
import cn.nubia.admin.sysconfig.query.DictQuery;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by Jason on 2015/7/5.
 */
@Service
public class DictService extends BaseServiceImpl<Dict> {

    public List<Dict> findList(DictQuery dictQuery) {
        Query<Dict> query = Query.build(Dict.class);
        query.addEq("groupValue", dictQuery.getGroupValue());
        query.addEq("enable", dictQuery.getEnable());
        return findByQuery(query);
    }

    public void save(Dict dict) {
        if (null == dict.getId()) {
            dict.setCreateTime(new Date());
            insert(dict);
        } else {
            update(dict);
        }
    }
}
